package com.xbn.xbnmall.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author XBN
 * @date 2020/8/11 13:54
 * @email 78742541@qq.com
 */
@Configuration
public class MyThreadConfig {
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(ThreadPollConfigProperties threadPollConfigProperties){
     return    new ThreadPoolExecutor(threadPollConfigProperties.getCoreSize()
             ,threadPollConfigProperties.getMaxSize(),
             threadPollConfigProperties.getKeepAliveTime(), TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(50000), Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
    }
}
